using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// 粒子光环随鼠标移动且点击控制缩放效果
public class FollowMouse : MonoBehaviour
{
    private OuterRing outerRing;
    private InnerRing innerRing;

    // Start is called before the first frame update
    void Start()
    {
        // 获取南外环对象
        outerRing = GetComponentInChildren<OuterRing>();
        innerRing = GetComponentInChildren<InnerRing>();
        
    }

    // Update is called once per frame
    void Update()
    {
        // 跟随鼠标(最后的参数为粒子光环与鼠标垂直距离)
        Vector3 m_MousePos = new Vector3(Input.mousePosition.x,Input.mousePosition.y,50);
        transform.position = Camera.main.ScreenToWorldPoint(m_MousePos);

        // 鼠标左键点击控制粒子光环缩放
        if (Input.GetMouseButtonDown(0)){
            outerRing.isCollected = true;
            innerRing.isCollected = true;
        }
        if (Input.GetMouseButtonUp(0)){
            outerRing.isCollected = false;
            innerRing.isCollected = false;
        }
    }
}